package io.renren.modules.interviewer.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.interviewer.entity.HrInforEntity;
import io.renren.modules.interviewer.service.HrInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 面试官信息表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-12-30 21:23:15
 */
@RestController
@RequestMapping("interviewer/hrinfor")
public class HrInforController {
    @Autowired
    private HrInforService hrInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("interviewer:hrinfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = hrInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{hrId}")
    @RequiresPermissions("interviewer:hrinfor:info")
    public R info(@PathVariable("hrId") Long hrId){
        HrInforEntity hrInfor = hrInforService.getById(hrId);

        return R.ok().put("hrInfor", hrInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("interviewer:hrinfor:save")
    public R save(@RequestBody HrInforEntity hrInfor){
        hrInforService.save(hrInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("interviewer:hrinfor:update")
    public R update(@RequestBody HrInforEntity hrInfor){
        ValidatorUtils.validateEntity(hrInfor);
        hrInforService.updateById(hrInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("interviewer:hrinfor:delete")
    public R delete(@RequestBody Long[] hrIds){
        hrInforService.removeByIds(Arrays.asList(hrIds));

        return R.ok();
    }

}
